package com.example.demo.pojo.response;


import com.example.demo.constant.Constants;
import lombok.Data;

@Data
public class Result<T> {
    private int code;
    private String errMsg;
    private T data;

    public static <T> Result<T> success(T data){
        Result<T> result=new Result();
        result.setCode(Constants.SUCCESS_CODE);
        result.setData(data);
        return result;
    }
    public static <T> Result<T> fail(String errMsg){
        Result<T> result=new Result();
        result.setCode(Constants.Fail_CODE);
        result.setErrMsg(errMsg);
        return result;
    }
    public static <T> Result<T> fail(T data,String errMsg){
        Result<T> result=new Result();
        result.setCode(Constants.Fail_CODE);
        result.setData(data);
        result.setErrMsg(errMsg);
        return result;
    }
}
